<?php
	//view notes
	
	if(!empty($neighbors['prev'])) {
		echo '<p>', $html->link('Previous Delivery, ' . date('m-d-Y', strtotime($neighbors['prev']['Delivery']['delivery_open'])), array('controller'=>'notes', 'action'=>'view', $neighbors['prev']['Delivery']['delivery_id'])), '</p>';
	}
	
	if(!empty($neighbors['next'])) {
		echo '<p>', $html->link('Next Delivery, ' . date('m-d-Y', strtotime($neighbors['next']['Delivery']['delivery_open'])), array('controller'=>'notes', 'action'=>'view', $neighbors['next']['Delivery']['delivery_id'])), '</p>';
	}
?>

<table>
	<tr>
		<th>From</th>
		<th>Re:</th>
		<th>Note</th>
		<th>Adj</th>
	</tr>
<?php

foreach($notes as $note) {
	$re = '';
	if ($note['Note']['table_name'] == 'members') {
		$re = $html->link(sprintf("%s %s's Invoice", $note['Regarding']['Member']['first_name'], $note['Regarding']['Member']['last_name']), '/members/basket/' . $note['Regarding']['Member']['member_id']);
	} else if ($note['Note']['table_name'] == 'producers') {
		$re = sprintf("%s Invoice", $note['Regarding']['Member']['business_name']);
	} else if ($note['Note']['table_name'] == 'basket_items') {
		$re = 'A Basket Item.  Descriptive, eh?';
	}
?>

	<tr>
		<td><?=$note['From']['username']?></td>
		<td><?=$re?></td>
		<td><?=$note['Note']['text']?></td>
		<td><?='$' . number_format($note['Note']['adj_amount'], 2)?></td>
	</tr>
	
<?php
}
?>
</table>